SWAGOLX.EXE (c) 1993 GDSOFT ALL RIGHTS RESERVED 00002 1 08-24-9413:49ALL FRANK DIACHEYSN Command Paramaters SWAG9408 éε 7 D {π Coded By Frank Diacheysn Of Gemini Softwareππ FUNCTION PARAMETERSππ Input......: Noneπ :π :π :π :ππ Output.....: Command Line Used To Execute The Current Programπ :π :π :π :ππ Example....: IF POS('/F',PARAMETERS) THENπ : WriteLn('/Full Option Enabled.')π : ELSEπ : WriteLn('/Full Option Disabled.');π :ππ Description: Function To Return The Entire Command Line That Was Used Toπ : Execute The Current Programπ :π :π :ππ}πFUNCTION PARAMETERS : STRING;πBEGINπ PARAMETERS := STRING( PTR( PREFIXSEG, $0080 )^ );πEND;π 2 08-24-9413:59ALL MARK OUELLET Parsing A String SWAG9408 ?≥▓σ 26 D {πRN> I have a routine in one of my programs that that reads a delimited stringπRN> from a configuration file, the string is defined such as: ~040~055~099~144πRN> etc. (these are message base area numbers)ππRN> In the program a check is done to see if the current area exists or doesπRN> not exist in the list via a simple Pos() function.ππRN> Works great! but.......ππRN> I have been asked to include the capabilty to include a RANGE of numbers inπRN> this list, this being due to the 255 char limit of a normal string.πππRN> So lets assume the list above will look like this:ππRN> ~040~055~060-080~099~144ππRN> How can I pull out the 060-080 and include all numbers between into theπRN> list or actually, do a check, possibly creating a Set?ππRN> OR would I have to create another function/configuration item to do this?ππRN> I hope my explanation of what I wish to accomplish can be understood. <g>ππRN> All replies are very welcomed!!ππTry this, the code is ugly but it works!π{Written, Tested and Compiled with BP 7.x}ππuses crt;ππtypeπ Str3 = string[3];πvarπ Area, RangeLo, RangeHi : str3;π List : String;ππfunction Found(List:string;Area:str3):boolean;πbeginπ if Pos(Area, List)>0 then beginπ Found := true;π end else beginπ {π Area not found yet, are there ranges??π }π if Pos('-', List)>0 then beginπ {π Yes! Process rangesπ }π while Pos('-', List) > 0 do beginπ RangeLo := Copy(List, Pos('-', List)-3, 3);π {π Area must be BETWEEN Lo and hi otherwise it would haveπ been found by the first POS check. So if RangeLo is > Areaπ No need to lose time extracting RangeHiπ }π if RangeLo<Area then beginπ RangeHi := Copy(List, Pos('-', List)+1, 3);π if RangeHi > Area then beginπ {π Lo < Area < hi, We found a Matchπ }π Found := true;π {π Kill list to exit while-loopπ }π List := '';π end else beginπ {π Kill this range's DASH, POS only reports the first matchπ }π Delete(List, Pos('-', List), 1);π end;π end else beginπ {π Kill this range's DASH, POS only reports the first matchπ }π Delete(List, Pos('-', List), 1);π end;π end;π {π Only two possibilities when we get hereπ 1- List = '' which means a match was found and list wasπ cleared to exit the while-loop.π 2- No match was found, in which case List is non-empty.π }π if List<>'' thenπ Found := false;π end else beginπ Found := false;π end;π end;πend;ππvarπ X : byte;ππbeginπ List := '~012~020~033~060-079~081~090~095-123~';π clrscr;π for X := 0 to 255 do beginπ Area := chr(48 + (X div 100)) +π chr(48 + ((X mod 100) div 10)) +π chr(48 + ((X mod 10)));π writeln(Area, ' ', List, ' ', Found(List, Area));π if (not boolean(x mod 24)) and (x>0) then beginπ while not keypressed do;π while keypressed do readkey;π clrscr;π end;π end;πend.ππ